package com.cqu.lpss.service.impl;

import com.cqu.lpss.mapper.ProjectMapper;
import com.cqu.lpss.pojo.Projects;
import com.cqu.lpss.service.ProjectInterface;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.List;

@Service
public class ProjectImpl implements ProjectInterface {
    @Autowired
    ProjectMapper projectMapper;
    @Override
    public Projects findByConId(String ConId) {
        Projects prj = projectMapper.findByConId(ConId);
        return prj;
    }

    @Override
    public int submit(Projects project) {
        project.setPrjCreatetime(new Timestamp(System.currentTimeMillis()));
        project.setPrjUpdatetime(new Timestamp(System.currentTimeMillis()));
        Projects ansprj = projectMapper.findByConId(project.getPrjConid());
        int ans=0;
        if(ansprj==null){
            ans = projectMapper.insert(project.getPrjConid(),project.getPrjRealname(),project.getPrjVirtname(),project.getPrjUrl(),project.getPrjCreatetime(),project.getPrjUpdatetime());
        }else {
            ans = projectMapper.uploadByConId(project.getPrjConid(),project.getPrjRealname(),project.getPrjVirtname(),project.getPrjUrl(),project.getPrjUpdatetime());
        }
        return ans;
    }

    @Override
    public int modifyPrjPublishFirstGrade() {
        return projectMapper.modifyPrjPublishFirstGrade();
    }

    @Override
    public int havepublishfirstGrade() {
        return projectMapper.havepublishfirstGrade();
    }

    @Override
    public Projects firstscorequery(String conId) {
        Projects queryfirstscore = projectMapper.queryfirstscore(conId);
        return  queryfirstscore;

    }

    @Override
    public List<Projects> passfirstPrj() {
        return projectMapper.passfirstPrj();
    }

    @Override
    public int updatepublishfinalscore() {
        return projectMapper.updatepublishfinalscore();
    }

    @Override
    public int havepublishfinalscore() {
        return projectMapper.havepublishfinalscore();
    }

    @Override
    public Projects finalscorequery(String conId) {

        return projectMapper.finalscorequery(conId);
    }

    @Override
    public List<Projects> passfinalprj() {
        return projectMapper.passfinalprj();
    }
}
